﻿using System.Data.Entity;
using HomeGuardBand.Models;

namespace HomeGuardBand.App_Data
{
    public class HomeGuardBandDbInitializer : DropCreateDatabaseAlways<HomeGuardBandContext>
    {
        protected override void Seed(HomeGuardBandContext context)
        {
            
            var ds = new DefaultData();

            ds.Composers.ForEach(composer => context.Composers.Add(composer));

            foreach (var location in ds.Locations)
            {
                context.Locations.Add(location);
            }
            foreach (var musician in ds.Members)
            {
                context.Members.Add(musician);
            }
            foreach (var instrument in ds.Instruments)
            {
                context.Instruments.Add(instrument);
            }

            ds.InstrumentTypes.ForEach(instrumentType => context.InstrumentTypes.Add(instrumentType));
        
            context.SaveChanges();
        }
    }
}